#include <cstdio>
#include <cmath>

int main( )
{
    int i, t, n;
    scanf("%d", &t);
    while ( t-- )
    {
        scanf("%d", &n);
        for ( i = int( sqrt( n ) ); i > 0; i-- )
            if ( n % i == 0 && n / i != i && ( n / i - i ) % 2 == 0 )
            {
                printf("%d\n", ( n / i - i ) / 2);
                break;
            }
        if ( i == 0 ) puts("-1");
    }
    return 0;
}
